{extend name="$member_style_layout" /}

{block name="title"}充值{/block}
{block name="content"}
<div class="WapFormContainer">
	<div class="tag">提现 {if $getout_percent_money>0}(手续费<span style="color:red;">{$getout_percent_money}%</span>){/if}</div>
	<form name="form1" method="post" action="" class="ajax_post">
		<ul>
			<ol>可用余额:</ol>
			<li><span class="b red">{$userdb.rmb}</span>元 </li>
		</ul>
		<div style="text-align:right;padding-right:8px;" id="getrealmoney"> </div>
		<ul>
			<ol>提现金额为:(<span class="red">*</span>)</ol>
			<li><input id="getoutmoney" type="number" name="money" placeholder="输入金额"/></li>
		</ul>
{if $webdb.jifen2getoutmoney&&$getout_percent_money>0}
        <div style="text-align:right;padding-right:8px;font-size:13px;">{$webdb.MoneyName}抵扣手续费，每个可抵 <font style="color:blue;">{:abs($webdb.money_ratio/100)}</font> 元，<span style="display:none;" id="jifenmsg">最多可用 <font style="color:blue;" id="maxjifen">{$userdb.money}</font> 个抵扣 <font id="maxmoney" style="color:blue;">0</font> 元</span></div>
		<ul>
			<ol>抵扣的{$webdb.MoneyName}数量（个）:</ol>
			<li><input id="payjifenNum" placeholder='你共有{$userdb.money}个' type="number" name="jifen"/></li>
		</ul>
{/if}
		<ul>
			<ol>支付密码:(<span class="red">*</span>)</ol>
			<li><input type="password" name="pwd" placeholder="输入密码"/></li>
		</ul>
		<dl>
            <dt>请选择提现到哪个收款帐户:(<span class="red">*</span>)</dt>
            <dd>
{notempty name="$userdb.weixin_api"}
				<div><input type="radio" name="banktype" value="weixin 微信钱包" checked="true">微信钱包 (强烈推荐,即绑定登录的微信)</div>
{/notempty}
{notempty name="$alipay_id"}
				<div><input type="radio" name="banktype" value="支付宝 {$alipay_id}">支付宝{$alipay_id}</div>
{/notempty}
{volist name="listdb" id="rs"}
              <div><input type="radio" name="banktype" value="{$rs}">{$rs}</div>
{/volist}
          	</dd>     
      	</dl>
      	<ul>
			<ol>收款人真实姓名:(<span class="red">*</span>)</ol>
			<li><input type="text" name="truename" placeholder="输入姓名"/></li>
		</ul>
		<ul>
			<ol>联系电话:(选填)</ol>
			<li><input type="text" name="tel" placeholder="输入电话"/></li>
		</ul>
		<dl>
	        <dt>提现备注:(选填)</dt>
	        <dd><textarea name="why" placeholder="输入备注内容"></textarea></dd>
	    </dl>
		<dl>
	        <dt>签名:(<span class="red">必填</span>)</dt>
	        <dd><div id="signature" style="width:100%;height:200px;border:1px solid red;"></div>
				<input id="clear" type="button" value="清除签名">
			    <input id="save" type="button" value="确认签名">
				<input type="hidden" name="sign_img" id="sign_img">
			</dd>
	    </dl>
	    <div class='butter'>
            <button type="submit">提交</button>
            <input type="hidden" name="step" value="2">            
        </div>
        <dl>
			<dt>注意事项</dt>
			<dd>
				<div>1.提现最低金额不小于<span style="color:red;font-weight:bold;">{$webdb.min_getout_money|default=50}</span>元,才可提现。{if $getout_percent_money>0}提现会从申请的金额当中扣除 <span style="color:red;font-weight:bold;">{$getout_percent_money}%</span> 作为手续费.{/if}</div>
			  	<div>2.提现金额将会被冻结不可用.推荐选择微信钱包</div>
				<div>3.资料提交后,需人工审核,要1-3天时间处理(遇节假日会延长),请耐心等待.</div>
				{if $webdb.getout_rmb_tn}<div>4.提现T+N周期是 {$webdb.getout_rmb_tn} 天,即最近 {$webdb.getout_rmb_tn} 天内的收入暂不可提现。</div>{/if}
				{if $webdb.getout_need_join_mp}<div>5.提现需要先关注公众号，以方便接收提现动态提醒。</div>{/if}				
				{if ($webdb.getout_need_join_mp && $webdb.mp_code_img)}<div><img style="max-width:80%;" src="{$webdb.mp_code_img|tempdir}"></div>{/if}
		  	</dd>          
        </dl>
	</form>
</div>


<script type="text/javascript" src="__STATIC__/libs/jsignature/jSignature.min.noconflict.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$("#signature").jSignature({height:"100%",width:"100%",color:"#000",lineWidth:5})
			});
			$("#clear").click( function() {
				$("#signature").jSignature("reset");
			});
			$("#save").click( function() {
				var datapair = $("#signature").jSignature("getData", "image");
				var array = datapair.splice(",");
				$.post("{:iurl('index/attachment/upload','dir=images&from=base64&module=marketing')}",{imgBase64:'data:image/png;base64,'+array[1]},res=>{
					if(res.code==1){
						$("#sign_img").val(res.url);
						layer.msg('保存成功');
					}else{
						alert('保存失败');
					}
				});
			});
			/*
			$("#export").click( function() {
				var datapair = $("#signature").jSignature("getData", "image");
				var i = new Image();
				i.src = "data:" + datapair[0] + "," + datapair[1];
				$(i).appendTo($("#pic"));
			});
			*/
</script>


<script type="text/javascript">

$(function(){
	var totaljifen;
	var realJFmoney = 0;
	var realmoney;
	$("#getoutmoney").blur(function(){
		if($(this).val()==''){
			return ;
		}
		if($(this).val()>{$userdb.rmb}){
			layer.alert("提现金额不能大于你的实际可用余额 {$userdb.rmb} 元！");
			return ;
		}else if($(this).val()!='' && $(this).val()<0.01){
			layer.alert("提现金额不能小于0.01元");
			return ;
		}
		realmoney = Number( parseFloat(Number($(this).val())*(100-{$getout_percent_money})/100).toFixed(2) );
		showrealmoney();
		var paymoney = Number( parseFloat(parseFloat($(this).val()) - realmoney).toFixed(2) );
		totaljifen = paymoney*{$webdb.money_ratio};
		if(totaljifen>{$userdb.money}){
			totaljifen = {$userdb.money};
		}
		var jifenmoney = totaljifen/{$webdb.money_ratio};
		$("#maxjifen").html(totaljifen);
		$("#maxmoney").html(jifenmoney);
		$("#jifenmsg").show();
	});

	$("#payjifenNum").blur(function(){
		if($(this).val()==''){
			return ;
		}
		if($("#getoutmoney").val()==''){
			layer.alert("请先输入提现金额！");
			$(this).val('')
			return ;
		}
		var num = Number($(this).val());
		if(num<0){
			layer.alert("不能是负数");
			return ;
		}else if(num>totaljifen){
			layer.alert("不能大于 "+totaljifen+" 个");
			return ;
		}
		realJFmoney = Number( parseFloat(num/{$webdb.money_ratio}).toFixed(2) );
		showrealmoney();
	});

	function showrealmoney(){
		$("#getrealmoney").html("实际可到帐 <font style='color:red;'>"+realmoney+ (realJFmoney>0?"+"+realJFmoney:'') +"</font> 元");
	}
});
</script>
<!-- 表单常用事件,比如无刷新提交 -->
<script LANGUAGE="JavaScript" src="__STATIC__/js/form/base.js"></script>

{/block}